﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Domain;
using Business;
using System.Web.Configuration;

namespace HotelBrisaYArenaAdministrador
{
    public partial class Site : System.Web.UI.MasterPage
    {
        ImagenBusiness imgBusiness = new ImagenBusiness(WebConfigurationManager.ConnectionStrings["ApplicationServices"].ToString());
        protected void Page_Load(object sender, EventArgs e)
        {

            if (Session["Administrador"] != null)
            {
                Administrador adm = (Administrador)Session["Administrador"];
                this.Label1.Text = adm.Usuario;
                Imagen imagen = new Imagen();
                imagen = imgBusiness.GetImagen(adm.IdImagen);
                byte[] imageBytes = imagen.Image;
                string base64ImageString = ConvertBytesToBase64(imageBytes);
                Image2.Src = "data:image/jpg;base64," + base64ImageString;
            }

            else
            {

                Response.Redirect("PaginaInicio.aspx?");
            }
        }
        public string ConvertBytesToBase64(byte[] imageBytes)
        {
            return Convert.ToBase64String(imageBytes);
        }

        protected void LinkButton1_Click(object sender, EventArgs e)
        {
            Session.Clear();
            Session.Abandon();
            Response.Redirect("PaginaInicio.aspx");
        }

    }
}